from django.db import models
from django.conf import settings
from contractsign.models import SoftContract

class SoftAdContent(models.Model):
    contract = models.OneToOneField(
        SoftContract,
        on_delete=models.CASCADE,
        related_name='ad_content'  # ✅ 明确反向名，防止冲突
    )
    editor = models.ForeignKey(
        settings.AUTH_USER_MODEL,
        on_delete=models.CASCADE,
        related_name='edited_ads'  # ✅ 明确用户反向名
    )
    content = models.TextField()
    image_path = models.CharField(max_length=255, blank=True)
    video_path = models.CharField(max_length=255, blank=True)
    STATUS_CHOICES = [
        ('pending', '待审核'),
        ('approved', '已通过'),
        ('rejected', '已驳回'),
    ]
    status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='pending')

    def __str__(self):
        return f"编辑 {self.editor.username} -> 合同 {self.contract.id}"
